package com.zuoyongyu;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/req_test1")
public class RequestTest1 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /**
         * 请求级 针对一次请求有效
         */
        req.setAttribute("uname","req_test");
        //服务器内部跳转 一次请求有效
        req.getRequestDispatcher("req_test2").forward(req,resp);

        //客服端跳转，二次请求 无效
//        resp.sendRedirect("req_test2");
    }
}
